home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Games Special 4 / THE BEST OF SELECT Games Special 4 (Select CD-ROM)(1996).iso / dosgames / abuse / lisp / weapons.lsp < prev   
Lisp/Scheme  |  1995-09-13  |  13KB  |  473 lines

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licensing information for more details on usage rights
  3.  
  4.  
  5. (defun mbullet_ai ()
  6.   (if (> (state_time) 5)
  7.       nil
  8.     (let ((bx (bmove (if (> (total_objects) 0) (get_object 0) nil))))  ; don't hit the guy who fired us.
  9.       (if (eq bx T)
  10.       T
  11.     (progn 
  12.       (if (null bx)
  13.           (if (eq (random 2) 0)
  14.           (progn
  15.             (add_panim MGUN_HIT1 (x) (y) (direction))
  16.             (play_sound MG_HIT_SND1 127 (x) (y)))
  17.         (progn
  18.           (add_panim MGUN_HIT2 (x) (y) (direction))
  19.           (play_sound MG_HIT_SND2 127 (x) (y))))
  20.         (progn
  21. ;          (add_panim EXPLO2 (x) (y) (direction))
  22. ;          (add_object EXP_LIGHT (x) (y) 80)    
  23.           (do_damage 5 bx (if (> 0 (direction)) -10 10) 0)
  24.           ))
  25.       nil))))
  26. )
  27.  
  28. (defun grenade_ai ()
  29.   (if (and (eq (tick) 0)
  30.        (if (< (total_objects) 1)
  31.            nil         
  32.          (let ((mex (x))
  33.            (mey (y)))
  34.            (not (with_object (get_object 0) (find_object_in_area (- mex 7) 
  35.                                      (- mey 7) 
  36.                                      (+ mex 7) 
  37.                                      (+ mey 7) bad_guy_list))))))
  38.       (progn (next_picture) T)
  39.     (do_explo 40 36)))
  40.  
  41. (defun fb_draw () nil)   ;; only draw while in the air
  42.  
  43. (defun firebomb_ai ()
  44.  
  45.   (add_object EXPLODE1 (- (x) (random 5)) (+ (y) (random 20)) 0)
  46.   (hurt_radius (x) (y) 60 40 (if (> (total_objects) 0) (get_object 0) nil) 10)     
  47.  
  48.   (and (or (< (state_time) 3) (not (eq (xvel) 0)))
  49.        (< (state_time) 20)
  50.        (select (direction)
  51.           (1 (progn ;(set_xvel 30) 
  52.             (not (blocked_right (move 0 0 0)))
  53.             ))
  54.           (-1 (progn ;(set_xvel -30) 
  55.              (not (blocked_left (move 0 0 0))))))))
  56.       
  57.  
  58.  
  59.  
  60.  
  61. (defun mbullet_ufun (creator) 
  62.   (set_direction (with_object creator (direction)))
  63.  
  64.   (let ((start (if (> (direction) 0) 335 155))
  65.     (end   (if (> (direction) 0) 25 205)))
  66.     (let ((target (with_object creator (find_object_in_angle start end bad_guy_list))))
  67.       (if (and target (< (abs (- (x) (with_object target (x)))) 150)
  68.            (< (abs (- (y) (with_object target (y)))) 100))
  69.       (set_course (site_angle target) 50)
  70.     (if (> (direction) 0)
  71.         (set_course 0 50)
  72.       (set_course 180 50)))))
  73.  
  74.   (link_object creator)
  75. )
  76.  
  77.  
  78. (defun firebomb_ufun (creator) 
  79.   (set_direction (with_object creator (direction)))
  80.   (link_object creator)
  81. )
  82.  
  83.  
  84.  
  85. (defun player_mine_ufun (creator) 
  86.   (set_x (with_object creator (x)))
  87.   (set_y (with_object creator (y)))
  88.   (link_object creator)
  89.   (let ((me (me)))
  90.     (with_object creator (link_object me)))
  91. )
  92.  
  93. (defun player_mine_ai ()
  94.   (select (aistate)
  95.       (0
  96.        ;; wait till no player (just in case), or player lets go of fire button  
  97.        (if (or (eq 0 (total_objects)) 
  98.            (and (eq (with_object (get_object 0) (player_b1_suggest)) 0)
  99.             (eq (with_object (get_object 0) (player_b2_suggest)) 0)))
  100.            (progn
  101.          (set_state blocking)
  102.          (set_aistate 1)
  103.          T)
  104.          T))
  105.       (1 (if (next_picture)
  106.          T
  107.            (do_explo 50 40)
  108.          ))))
  109.       
  110.  
  111. (def_char MBULLET
  112.   (funs (ai_fun     mbullet_ai)  
  113.     (draw_fun   dev_draw)     ; you can't see the bullets
  114.     (user_fun   mbullet_ufun))
  115.   (range 10000 10000)
  116.   (flags (unlistable T))
  117.   (states "art/misc.spe" (stopped "mbullet_icon")))
  118.  
  119.  
  120. (defun grenade_ufun (creator) 
  121.   (set_direction (with_object creator (direction)))
  122.   (play_sound GRENADE_THROW 127 (x) (y))
  123.   (select (aitype)
  124.       (1 (progn (set_xvel (if (> (direction) 0) 
  125.                   (+ 13 (random 2)) 
  126.                 (+ -13 (random 2)))) (set_yvel -4)))
  127.       (2 (progn (set_xvel (if (> (direction) 0) 
  128.                   (+ 7 (random 2)) 
  129.                 (+ -7 (random 2)))) (set_yvel -10))))
  130.   (set_xvel (+ (xvel) (with_object creator (xvel))))
  131.   (link_object creator)
  132. )
  133.  
  134. (defun grenade_cache (type)
  135.   (list (list EXPLODE1 EXP_LIGHT) 
  136.     (list GRENADE_SND)))
  137.  
  138.  
  139. (def_char GRENADE
  140.   (funs (ai_fun   grenade_ai)  
  141.     (get_cache_list_fun grenade_cache)
  142.     (user_fun grenade_ufun))
  143.   (range 10000 10000)
  144.   (flags (unlistable  T))
  145.   (states "art/misc.spe" (stopped (seq "4gre" 1 8))))
  146.  
  147.  
  148. (def_char FIREBOMB
  149.   (funs (ai_fun   firebomb_ai)  
  150.     (user_fun firebomb_ufun)
  151.     (get_cache_list_fun grenade_cache)
  152.     (draw_fun fb_draw))
  153.   (abilities (walk_top_speed  20)
  154.          (run_top_speed   20))
  155.   (range 10000 10000)
  156.   (flags (unlistable T))
  157.   (states "art/misc.spe"
  158.       (stopped "firebomb")
  159.       (walking "firebomb")))
  160.  
  161. (defun giver (type)
  162.   (let ((amount (get_ability start_hp)))
  163.     (with_object (bg)
  164.          (progn 
  165.            (if (and (not (has_weapon type)) change_on_pickup)
  166.                (set_current_weapon type))
  167.            (give_weapon type)
  168.            (add_ammo type amount)))))
  169.  
  170. (defun weapon_icon_ai () 
  171.   (if (activated)
  172.       (progn
  173.     (try_move 0 10)
  174.     (if (touching_bg) 
  175.         (progn
  176.           (play_sound AMMO_SND 127 (x) (y))
  177.           (select (otype)
  178.               (MBULLET_ICON5   (giver 0))    ;; these numbers correspond to status bar position
  179.               (MBULLET_ICON20  (giver 0))
  180.               (GRENADE_ICON2   (giver 1))        
  181.               (GRENADE_ICON10  (giver 1))
  182.  
  183.               (ROCKET_ICON2    (giver 2))
  184.               (ROCKET_ICON5    (giver 2))
  185.  
  186.               (FBOMB_ICON1     (giver 3))
  187.               (FBOMB_ICON5     (giver 3))
  188.  
  189.               (PLASMA_ICON20   (giver 4))
  190.               (PLASMA_ICON50   (giver 4))
  191.  
  192.               (LSABER_ICON50   (giver 5))
  193.               (LSABER_ICON100  (giver 5))
  194.  
  195.               (DFRIS_ICON4     (giver 6))
  196.               (DFRIS_ICON10    (giver 6))
  197.  
  198.               )
  199.  
  200.           nil)
  201.       T))
  202.     T))
  203.     
  204. (defun on_draw ()
  205.   (if (activated)
  206.       (draw)
  207.     (dev_draw)))
  208.       
  209.  
  210. (defun ammo_cache (type)    ;; tells what other chars to load in with this character
  211.   (list
  212.    (select type
  213.        (GRENADE_ICON2    `(,GRENADE ,GRENADE_TOP))
  214.        (GRENADE_ICON10   `(,GRENADE ,GRENADE_TOP))
  215.        (MBULLET_ICON5    `(,SHOTGUN_BULLET ,MGUN_TOP))
  216.        (MBULLET_ICON20   `(,SHOTGUN_BULLET ,MGUN_TOP))
  217.        (ROCKET_ICON2     `(,ROCKET ,ROCKET_TOP))
  218.        (ROCKET_ICON5     `(,ROCKET ,ROCKET_TOP))      
  219.        (FBOMB_ICON1      `(,FIREBOMB ,FIREBOMB_TOP))
  220.        (FBOMB_ICON5      `(,FIREBOMB ,FIREBOMB_TOP))
  221.  
  222.        (PLASMA_ICON20    `(,PLASMAGUN_BULLET))
  223.        (PLASMA_ICON50    `(,PLASMAGUN_BULLET))       
  224.  
  225.        (LSABER_ICON50    `(,LSABER_BULLET ,PGUN_TOP))
  226.        (LSABER_ICON100   `(,LSABER_BULLET ,PGUN_TOP))
  227.  
  228.        (DFRIS_ICON4      `(,DFRIS_BULLET ,DFRIS_TOP))
  229.        (DFRIS_ICON10     `(,DFRIS_BULLET ,DFRIS_TOP))
  230.    nil)))
  231.  
  232. (defun make_ammo_icon (symbol icon_name increment)
  233.   (eval (list 'def_char symbol          
  234.           '(funs (ai_fun weapon_icon_ai)
  235.              (get_cache_list_fun ammo_cache)
  236.              (draw_fun on_draw))
  237.           '(range 5 5)
  238.           '(flags (add_front T))
  239.           `(abilities (start_hp ,increment))
  240.           `(states  "art/chars/ammo.spe" (stopped ,icon_name)))))
  241.  
  242. (make_ammo_icon 'GRENADE_ICON2  "grenade_small" 2 )
  243. (make_ammo_icon 'GRENADE_ICON10 "grenade_large" 10)
  244.  
  245. (make_ammo_icon 'MBULLET_ICON5  "bullets_small"  5)
  246. (make_ammo_icon 'MBULLET_ICON20 "bullets_large" 20)
  247.  
  248. (make_ammo_icon 'FBOMB_ICON1 "firebomb_small"   1)
  249. (make_ammo_icon 'FBOMB_ICON5 "firebomb_large"   5)
  250.  
  251. (make_ammo_icon 'ROCKET_ICON2 "rocket_small"      2)
  252. (make_ammo_icon 'ROCKET_ICON5 "rocket_large"      5)
  253.  
  254.  
  255.  
  256. (defun guner_cons () 
  257.   (set_xvel 7)     ;; fire speed
  258.   (set_yvel 50)    ;; speed of bullet
  259.   (set_xacel 290)  ;; start angle
  260.   (set_yacel 359)  ;; end angle
  261. )
  262.  
  263.  
  264. (defun guner_damage (amount from hitx hity push_xvel push_yvel)  ; transfer damage to lower half
  265.   (if (not (eq (state) stopped))
  266.       (progn
  267.     (add_object EXPLODE3 (+ hitx (random 5)) (+ hity (random 5)) 0)
  268.     (add_object EXPLODE2 (+ hitx (random 5)) (+ hity (random 5)) 2)
  269.     (add_object EXPLODE3 (- hitx (random 5)) (- hity (random 5)) 1)
  270.     (add_object EXPLODE3 (- hitx (random 5)) (- hity (random 5)) 2)
  271.  
  272.     (damage_fun amount from hitx hity 0 0)     ; don't allow pushing
  273.  
  274.     (if (<= (hp) 0)
  275.         (progn
  276.           (play_sound BLOWN_UP 127 (x) (y))
  277.           (add_object EXPLODE1 (- hitx (random 10)) (- hity (random 25)) 0)      
  278.           (add_object EXPLODE1 (+ hitx (random 10)) (+ hity (random 25)) 1)      
  279.           (add_object EXPLODE1 (- hitx (random 10)) (- hity (random 10)) 2)      
  280.           (add_object EXPLODE1 (+ hitx (random 10)) (+ hity (random 10)) 3) ))))
  281. )
  282.  
  283.  
  284.  
  285.  
  286.  
  287.         
  288. (defun shot_ai () (eq (bmove nil) T))
  289. (defun gun_ai ()
  290.   (if (> (hp) 0)
  291.       (progn
  292.     (select (state)
  293.         (stopped (if (> (state_time) (xvel))
  294.                  (let ((a (site_angle (bg)))
  295.                    (me (me))
  296.                    (speed (yvel)))
  297.                    (if (eq (aitype) 1)
  298.                    (print a))        ;; show the angle for level designers
  299.